{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 题目\n",
    "某餐饮企业的增长陷入迟滞，同时不同菜品口味和不同经营模式的餐馆更是层出不穷。在内忧外患的情况下，该餐饮企业希望结合餐饮行业现状，分析客户和订单的数据，挖掘数据中的信息，通过对客户流失进行预测寻找到相应对策，从而提高利润。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 导出依赖库"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "客户信息表的维度：\n",
      " (2431, 36)\n",
      "订单详情表的维度：\n",
      " (6611, 21)\n"
     ]
    }
   ],
   "source": [
    "users = pd.read_csv(\"../data/user_loss.csv\", encoding='gbk')\n",
    "info = pd.read_csv(\"../data/info_new .csv\", encoding='utf-8')\n",
    "print(\"客户信息表的维度：\\n\", users.shape)\n",
    "print(\"订单详情表的维度：\\n\", info.shape)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "在这里可以看出数据中有2431条用户信息；6611条订单信息 "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 浏览客户信息表内容"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>USER_ID</th>\n",
       "      <th>MYID</th>\n",
       "      <th>ACCOUNT</th>\n",
       "      <th>NAME</th>\n",
       "      <th>ORGANIZE_ID</th>\n",
       "      <th>ORGANIZE_NAME</th>\n",
       "      <th>DUTY_ID</th>\n",
       "      <th>TITLE_ID</th>\n",
       "      <th>PASSWORD</th>\n",
       "      <th>EMAIL</th>\n",
       "      <th>...</th>\n",
       "      <th>MODIFYER</th>\n",
       "      <th>TEL</th>\n",
       "      <th>STUNO</th>\n",
       "      <th>QQ</th>\n",
       "      <th>WEIXIN</th>\n",
       "      <th>SEX</th>\n",
       "      <th>POO</th>\n",
       "      <th>ADDRESS</th>\n",
       "      <th>AGE</th>\n",
       "      <th>TYPE</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3300</td>\n",
       "      <td>NaN</td>\n",
       "      <td>艾朵</td>\n",
       "      <td>a2328</td>\n",
       "      <td>330</td>\n",
       "      <td>统计17级</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>202cb962ac59075b964b07152d234b1752</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>18688882452</td>\n",
       "      <td>2019351</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>男</td>\n",
       "      <td>广东汕尾</td>\n",
       "      <td>广州</td>\n",
       "      <td>26</td>\n",
       "      <td>非流失</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>3497</td>\n",
       "      <td>NaN</td>\n",
       "      <td>艾国真</td>\n",
       "      <td>a2525</td>\n",
       "      <td>330</td>\n",
       "      <td>统计17级</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>202cb962ac59075b964b07152d234b1949</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>18688882649</td>\n",
       "      <td>2019548</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>男</td>\n",
       "      <td>广东汕尾</td>\n",
       "      <td>广州</td>\n",
       "      <td>43</td>\n",
       "      <td>非流失</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2863</td>\n",
       "      <td>NaN</td>\n",
       "      <td>艾锦程</td>\n",
       "      <td>a1891</td>\n",
       "      <td>330</td>\n",
       "      <td>统计17级</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>202cb962ac59075b964b07152d234b1315</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>18688882015</td>\n",
       "      <td>2018914</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>男</td>\n",
       "      <td>广东汕尾</td>\n",
       "      <td>佛山</td>\n",
       "      <td>58</td>\n",
       "      <td>已流失</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3006</td>\n",
       "      <td>NaN</td>\n",
       "      <td>艾穹</td>\n",
       "      <td>a2034</td>\n",
       "      <td>330</td>\n",
       "      <td>统计17级</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>202cb962ac59075b964b07152d234b1458</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>18688882158</td>\n",
       "      <td>2019057</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>女</td>\n",
       "      <td>四川广安</td>\n",
       "      <td>广州</td>\n",
       "      <td>22</td>\n",
       "      <td>已流失</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>3160</td>\n",
       "      <td>NaN</td>\n",
       "      <td>艾融乐</td>\n",
       "      <td>a2188</td>\n",
       "      <td>330</td>\n",
       "      <td>统计17级</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>202cb962ac59075b964b07152d234b1612</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>18688882312</td>\n",
       "      <td>2019211</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>女</td>\n",
       "      <td>广东中山</td>\n",
       "      <td>广州</td>\n",
       "      <td>20</td>\n",
       "      <td>非流失</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2426</th>\n",
       "      <td>1986</td>\n",
       "      <td>NaN</td>\n",
       "      <td>左典之</td>\n",
       "      <td>a1014</td>\n",
       "      <td>330</td>\n",
       "      <td>统计17级</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>202cb962ac59075b964b07152d234b438</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>18688881138</td>\n",
       "      <td>2018037</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>男</td>\n",
       "      <td>广东中山</td>\n",
       "      <td>广州</td>\n",
       "      <td>27</td>\n",
       "      <td>已流失</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2427</th>\n",
       "      <td>3267</td>\n",
       "      <td>NaN</td>\n",
       "      <td>左翰飞</td>\n",
       "      <td>a2295</td>\n",
       "      <td>330</td>\n",
       "      <td>统计17级</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>202cb962ac59075b964b07152d234b1719</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>18688882419</td>\n",
       "      <td>2019318</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>男</td>\n",
       "      <td>广东湛江</td>\n",
       "      <td>广州</td>\n",
       "      <td>35</td>\n",
       "      <td>已流失</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2428</th>\n",
       "      <td>2998</td>\n",
       "      <td>NaN</td>\n",
       "      <td>左丽睿</td>\n",
       "      <td>a2026</td>\n",
       "      <td>330</td>\n",
       "      <td>统计17级</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>202cb962ac59075b964b07152d234b1450</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>18688882150</td>\n",
       "      <td>2019049</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>女</td>\n",
       "      <td>广西柳州</td>\n",
       "      <td>佛山</td>\n",
       "      <td>53</td>\n",
       "      <td>非流失</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2429</th>\n",
       "      <td>3163</td>\n",
       "      <td>NaN</td>\n",
       "      <td>左依杨</td>\n",
       "      <td>a2191</td>\n",
       "      <td>330</td>\n",
       "      <td>统计17级</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>202cb962ac59075b964b07152d234b1615</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>18688882315</td>\n",
       "      <td>2019214</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>女</td>\n",
       "      <td>广西玉林</td>\n",
       "      <td>深圳</td>\n",
       "      <td>59</td>\n",
       "      <td>已流失</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2430</th>\n",
       "      <td>3001</td>\n",
       "      <td>NaN</td>\n",
       "      <td>左真芯</td>\n",
       "      <td>a2029</td>\n",
       "      <td>330</td>\n",
       "      <td>统计17级</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>202cb962ac59075b964b07152d234b1453</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>18688882153</td>\n",
       "      <td>2019052</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>男</td>\n",
       "      <td>广东潮州</td>\n",
       "      <td>广州</td>\n",
       "      <td>44</td>\n",
       "      <td>已流失</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2431 rows × 36 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      USER_ID  MYID ACCOUNT   NAME  ORGANIZE_ID ORGANIZE_NAME  DUTY_ID  \\\n",
       "0        3300   NaN      艾朵  a2328          330         统计17级      NaN   \n",
       "1        3497   NaN     艾国真  a2525          330         统计17级      NaN   \n",
       "2        2863   NaN     艾锦程  a1891          330         统计17级      NaN   \n",
       "3        3006   NaN      艾穹  a2034          330         统计17级      NaN   \n",
       "4        3160   NaN     艾融乐  a2188          330         统计17级      NaN   \n",
       "...       ...   ...     ...    ...          ...           ...      ...   \n",
       "2426     1986   NaN     左典之  a1014          330         统计17级      NaN   \n",
       "2427     3267   NaN     左翰飞  a2295          330         统计17级      NaN   \n",
       "2428     2998   NaN     左丽睿  a2026          330         统计17级      NaN   \n",
       "2429     3163   NaN     左依杨  a2191          330         统计17级      NaN   \n",
       "2430     3001   NaN     左真芯  a2029          330         统计17级      NaN   \n",
       "\n",
       "      TITLE_ID                            PASSWORD  EMAIL  ...  MODIFYER  \\\n",
       "0          NaN  202cb962ac59075b964b07152d234b1752    NaN  ...       NaN   \n",
       "1          NaN  202cb962ac59075b964b07152d234b1949    NaN  ...       NaN   \n",
       "2          NaN  202cb962ac59075b964b07152d234b1315    NaN  ...       NaN   \n",
       "3          NaN  202cb962ac59075b964b07152d234b1458    NaN  ...       NaN   \n",
       "4          NaN  202cb962ac59075b964b07152d234b1612    NaN  ...       NaN   \n",
       "...        ...                                 ...    ...  ...       ...   \n",
       "2426       NaN   202cb962ac59075b964b07152d234b438    NaN  ...       NaN   \n",
       "2427       NaN  202cb962ac59075b964b07152d234b1719    NaN  ...       NaN   \n",
       "2428       NaN  202cb962ac59075b964b07152d234b1450    NaN  ...       NaN   \n",
       "2429       NaN  202cb962ac59075b964b07152d234b1615    NaN  ...       NaN   \n",
       "2430       NaN  202cb962ac59075b964b07152d234b1453    NaN  ...       NaN   \n",
       "\n",
       "              TEL    STUNO  QQ WEIXIN  SEX   POO  ADDRESS  AGE  TYPE  \n",
       "0     18688882452  2019351 NaN    NaN    男  广东汕尾       广州   26   非流失  \n",
       "1     18688882649  2019548 NaN    NaN    男  广东汕尾       广州   43   非流失  \n",
       "2     18688882015  2018914 NaN    NaN    男  广东汕尾       佛山   58   已流失  \n",
       "3     18688882158  2019057 NaN    NaN    女  四川广安       广州   22   已流失  \n",
       "4     18688882312  2019211 NaN    NaN    女  广东中山       广州   20   非流失  \n",
       "...           ...      ...  ..    ...  ...   ...      ...  ...   ...  \n",
       "2426  18688881138  2018037 NaN    NaN    男  广东中山       广州   27   已流失  \n",
       "2427  18688882419  2019318 NaN    NaN    男  广东湛江       广州   35   已流失  \n",
       "2428  18688882150  2019049 NaN    NaN    女  广西柳州       佛山   53   非流失  \n",
       "2429  18688882315  2019214 NaN    NaN    女  广西玉林       深圳   59   已流失  \n",
       "2430  18688882153  2019052 NaN    NaN    男  广东潮州       广州   44   已流失  \n",
       "\n",
       "[2431 rows x 36 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "users"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
